package com.kamistoat.meimeimall.common.taskEngine;

import lombok.Data;

import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 任务详情。将被投递到任务引擎中。
 */
@Data
public class EngineTaskDetail implements Runnable {
    /**
     * 已失败次数
     */
    private int failTimes = 0;
    /**
     * 任务所需参数
     */
    private Map<String, Object> taskParams;
    /**
     * 执行任务的目标线程池
     */
    private ThreadPoolExecutor threadPoolExecutor;
    /**
     * 执行任务的目标处理器
     */
    private AbstractEngineTaskExecutor engineTaskExecutor;

    public EngineTaskDetail(Map<String, Object> taskParams, AbstractEngineTaskExecutor engineTaskExecutor, ThreadPoolExecutor threadPoolExecutor) {
        this.taskParams = taskParams;
        this.engineTaskExecutor = engineTaskExecutor;
        this.threadPoolExecutor = threadPoolExecutor;
    }

    @Override
    public void run() {
        engineTaskExecutor.invoke(this);
    }
}
